﻿using System;
using System.Windows.Forms;
using DevExpress.XtraBars;
using UniMana.Data;

namespace UniMana.Win.Leadership
{
    public partial class FrmReportClass_Class_SubCourse : DevExpress.XtraEditors.XtraForm
    {
        public FrmReportClass_Class_SubCourse()
        {
            InitializeComponent();
            InitControlEvent();
        }
        public void InitControlEvent()
        {
            this.xucBar1.btnPrint_Click += 
                new UniMana.Utils.Controls.xucBar.ButtonClickHandler(
                    this.btnPrint_Click);
            //this.xucBar1.btnExport_Click += 
            //new UniMana.Utils.Controls.xucBar.ButtonClickHandler(
            //    this.btnExportExcel_Click);
        }
        private DBMain m_ReportClass_Course= new DBMain();
        private void ReportClass_Course_Load(object sender, EventArgs e)
        {
            grcClass_Course.DataSource = 
                m_ReportClass_Course.m_DCReadOnly.Training_Classes.GetReport_ClassByCourse(
                m_ReportClass_Course.m_DCReadOnly.Catalogue_Courses);
            cacClassCourse.DataSource = 
                m_ReportClass_Course.m_DCReadOnly.Training_Classes.GetReport_ClassByCourse(
                m_ReportClass_Course.m_DCReadOnly.Catalogue_Courses);
            cacClassCourse.Series[0].ArgumentDataMember = "Name";
            cacClassCourse.Series[0].TopNOptions.Enabled = true;
            cacClassCourse.Series[0].ArgumentDataMember = "Name";
            cacClassCourse.Series[0].Name = "Khóa học";
            cacClassCourse.Series[0].TopNOptions.Enabled = true;
            cacClassCourse.Series[0].ValueDataMembersSerializable = "Total";
        }
 
        private void btnPrint_Click(object sender, ItemClickEventArgs e)
        {
            //this.compositeLinkHienThi.RtfReportHeader = 
            //this.compositeLinkHienThi.RtfReportHeader.Replace(
            //    "nganh", UniMana.Utils.Helper.String.GetRtfUnicodeEscapedString(ctdt));
            
            compositeLinkHienThi.ShowPreviewDialog();
            
        }
        private void btnExportExcel_Click(object sender, ItemClickEventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "*.xlsx | *.xls";
            sfd.Title = "Lưu tập tin excel 2007";
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                compositeLinkHienThi.ExportToImage(sfd.FileName);
                //this.grvSubject.ExportToXlsx(sfd.FileName);
            }
            //;
        }
        
    }
}